前提条件:镜像烧录到硬盘中
network-config
)version: 2
ethernets:
eth0:
dhcp4: true
optional: true
wifis:
wlan0:
dhcp4: true
optional: true
access-points:
"你的wifi名称":
password: "你的wifi密码"
user-data
)#cloud-config
# 修改登录用户密码
chpasswd:
expire: false
list:
- ubuntu:123456
# ssh密码登录配置
ssh_pwauth: true
# 配置ntp服务器
ntp:
enable: true
servers:
- ntp2.aliyun.com
# 配置时区
timezone: Asia/Shanghai
# 配置apt的sources.list
apt:
preserve_sources_list: false
sources_list: |
deb https://mirrors.aliyun.com/ubuntu-ports $RELEASE main restricted
deb https://mirrors.aliyun.com/ubuntu-ports $RELEASE-updates main restricted
deb https://mirrors.aliyun.com/ubuntu-ports $RELEASE universe
deb https://mirrors.aliyun.com/ubuntu-ports $RELEASE-updates universe
deb https://mirrors.aliyun.com/ubuntu-ports $RELEASE multiverse
deb https://mirrors.aliyun.com/ubuntu-ports $RELEASE-updates multiverse
deb https://mirrors.aliyun.com/ubuntu-ports $RELEASE-backports main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu-ports $RELEASE-security main restricted
deb https://mirrors.aliyun.com/ubuntu-ports $RELEASE-security universe
deb https://mirrors.aliyun.com/ubuntu-ports $RELEASE-security multiverse
# 更新系统
package_update: true
package_upgrade: true
# 写文件
write_files:
# 配置 swappiness
- owner: root:root
content: vm.swappiness=60
path: /etc/sysctl.d/10-swappiness.conf
permissions: '0644'
# 配置交换文件: 2Gib
swap:
filename: /swap.img
size: 2147483648
maxsize: 2147483648
user-data
中配置swap交换分区,知道的请留言给我,谢谢!!!